FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app

# 设置端口
ENV ASPNETCORE_URLS=http://+:44378

# TIMEZONE
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# 安装fontconfig库，用于Pdf导出
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list || \
    echo "deb http://mirrors.aliyun.com/debian/ bookworm main" > /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian-security/ bookworm-security main" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian/ bookworm-updates main" >> /etc/apt/sources.list
RUN apt-get update && apt-get install -y fontconfig
# 复制字体文件
#COPY src/Wms.Manage.HttpApi.Host/fonts/* /usr/share/fonts/

# 添加以下命令来安装libgdiplus库，用于Excel导出
RUN apt-get install -y libgdiplus libc6-dev
RUN ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["NuGet.Config", "."]
COPY ["./src/Wms.Manager.HttpApi.Host/Wms.Manager.HttpApi.Host.csproj", "src/Wms.Manager.HttpApi.Host/"]
COPY ["./src/Wms.Manager.Application/Wms.Manager.Application.csproj", "src/Wms.Manager.Application/"]
COPY ["./src/Wms.Manager.Domain/Wms.Manager.Domain.csproj", "src/Wms.Manager.Domain/"]
COPY ["./src/Wms.Manager.Domain.Shared/Wms.Manager.Domain.Shared.csproj", "src/Wms.Manager.Domain.Shared/"]
COPY ["./src/Wms.Manager.Application.Contracts/Wms.Manager.Application.Contracts.csproj", "src/Wms.Manager.Application.Contracts/"]
COPY ["./src/Wms.Manager.EntityFrameworkCore/Wms.Manager.EntityFrameworkCore.csproj", "src/Wms.Manager.EntityFrameworkCore/"]
COPY ["./src/Wms.Manager.HttpApi/Wms.Manager.HttpApi.csproj", "src/Wms.Manager.HttpApi/"]
RUN dotnet restore "src/Wms.Manager.HttpApi.Host/Wms.Manager.HttpApi.Host.csproj"



COPY . .
WORKDIR "/src/src/Wms.Manager.HttpApi.Host"
RUN dotnet build "Wms.Manager.HttpApi.Host.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Wms.Manager.HttpApi.Host.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Wms.Manager.HttpApi.Host.dll"]
